package com.example.forecast.activity;

import androidx.appcompat.app.AppCompatActivity;

import android.graphics.Color;
import android.graphics.Typeface;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageButton;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.forecast.R;
import com.example.forecast.bean.DetailsBean;

public class LiuRenDetailsActivity extends AppCompatActivity {

    private TextView result, trigramWord, annotation, details;
    private ImageButton exit;
    private RelativeLayout relativeLayout;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_liu_ren_details);
        DetailsBean bean = (DetailsBean) getIntent().getSerializableExtra("data");


        relativeLayout = findViewById(R.id.rl_liuRenDetails_layout);
        result = findViewById(R.id.tv_liuRenDetails_result);
        trigramWord = findViewById(R.id.tv_liuRenDetails_trigramWord);
        annotation = findViewById(R.id.tv_liuRenDetails_annotation);
        details = findViewById(R.id.tv_liuRenDetails_details);
        exit = findViewById(R.id.ibtn_liuRenDetails_exit);

        switch (bean.getPalaceSite()) {
            case 0:
                relativeLayout.setBackgroundResource(R.drawable.qing_long);
                exit.setBackgroundResource(R.drawable.break_ql);
                break;
            case 1:
                relativeLayout.setBackgroundResource(R.drawable.xuan_wu);
                exit.setBackgroundResource(R.drawable.break_xw);
                break;
            case 2:
                relativeLayout.setBackgroundResource(R.drawable.zhu_que);
                exit.setBackgroundResource(R.drawable.break_zq);
                break;
            case 3:
                relativeLayout.setBackgroundResource(R.drawable.bai_hu);
                exit.setBackgroundResource(R.drawable.break_bh);
                break;
            case 4:
                relativeLayout.setBackgroundResource(R.drawable.liu_he);
                exit.setBackgroundResource(R.drawable.break_lh);
                break;
            case 5:
                relativeLayout.setBackgroundResource(R.drawable.gou_chen);
                exit.setBackgroundResource(R.drawable.break_gc);
                break;
            default:
                break;
        }
//        relativeLayout.getBackground().setAlpha(220);

        result.setText(bean.getResult());
        trigramWord.setText(bean.getTrigramWord());
        annotation.setText(bean.getAnnotation());
        details.setText(bean.getParticulars());

        Typeface typeface = Typeface.createFromAsset(getAssets(), "fonts/sszz.ttf");
        result.setTypeface(typeface);
        trigramWord.setTypeface(typeface);
        annotation.setTypeface(typeface);
        details.setTypeface(typeface);

        String color = "#FFFFFF";
        result.setTextColor(Color.parseColor(color));
        trigramWord.setTextColor(Color.parseColor(color));
        annotation.setTextColor(Color.parseColor(color));
        details.setTextColor(Color.parseColor(color));

        result.setTextSize(38f);
        trigramWord.setTextSize(20f);
        annotation.setTextSize(20f);
        details.setTextSize(20f);

        exit.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                LiuRenDetailsActivity.this.finish();
            }
        });
    }
}